package com.tudouji.project.quality.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.quality.domain.Qastandard;
import com.tudouji.project.quality.service.IQastandardService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 扣杂标准Controller
 * 
 * @author tudouji
 * @date 2021-03-08
 */
@RestController
@RequestMapping("/quality/qastandard")
public class QastandardController extends BaseController
{
    @Autowired
    private IQastandardService qastandardService;

    /**
     * 查询扣杂标准列表
     */
    @PreAuthorize("@ss.hasPermi('quality:qastandard:list')")
    @GetMapping("/list")
    public TableDataInfo list(Qastandard qastandard)
    {
        startPage();
        List<Qastandard> list = qastandardService.selectQastandardList(qastandard);
        return getDataTable(list);
    }

    /**
     * 导出扣杂标准列表
     */
    @PreAuthorize("@ss.hasPermi('quality:qastandard:export')")
    @Log(title = "扣杂标准", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Qastandard qastandard)
    {
        List<Qastandard> list = qastandardService.selectQastandardList(qastandard);
        ExcelUtil<Qastandard> util = new ExcelUtil<Qastandard>(Qastandard.class);
        return util.exportExcel(list, "qastandard");
    }

    /**
     * 获取扣杂标准详细信息
     */
    @PreAuthorize("@ss.hasPermi('quality:qastandard:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(qastandardService.selectQastandardById(guid));
    }

    /**
     * 新增扣杂标准
     */
    @PreAuthorize("@ss.hasPermi('quality:qastandard:add')")
    @Log(title = "扣杂标准", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Qastandard qastandard)
    {
        return toAjax(qastandardService.insertQastandard(qastandard));
    }

    /**
     * 修改扣杂标准
     */
    @PreAuthorize("@ss.hasPermi('quality:qastandard:edit')")
    @Log(title = "扣杂标准", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Qastandard qastandard)
    {
        return toAjax(qastandardService.updateQastandard(qastandard));
    }

    /**
     * 删除扣杂标准
     */
    @PreAuthorize("@ss.hasPermi('quality:qastandard:remove')")
    @Log(title = "扣杂标准", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(qastandardService.deleteQastandardByIds(guids));
    }

    @GetMapping("/findQastandardList")
    public AjaxResult findQastandardList(Qastandard qastandard)
    {
        List<Qastandard> list = qastandardService.selectQastandardList(qastandard);
        return AjaxResult.success(list);
    }
}
